const tag = {
    name: 'cinemas',
    description: "影院管理模块"
};

const schemas = {
    // 用于描述获取影院接口返回值
    ArrayOfCinemasReturn: {
        properties: {
            maxPage: {
                type: "number",
                description: "总页数",
            },
            total: {
                type: "number",
                description: "总数",
            },
            rows: {
                type: "array",
                description: "影院",
                items: {
                    $ref: "#components/schemas/cinemas"
                }
            },
        },

    },
    // 这是获取列表信息的补充
    cinemas: {
        properties: {
            _id: {
                type: "string",
                description: "影院唯一标识",
            },
            name: {
                type: "string",
                description: "影院名称",
            },
            address: {
                type: "string",
                description: "影院地址",
            },
            phone: {
                type: "number",
                description: "联系电话",
            },
            price: {
                type: "number",
                description: "票价",
            },
            distance: {
                type: "string",
                description: "距离",
            },
            status: {
                type: "string",
                description: "影院是否开启",
            },
        }
    },
    // 删除图片
    deleteImg: {
        properties: {
            imgs: {
                type: "array",
                description: "图片地址",
            },
            _id: {
                type: "string",
                description: "影院唯一标识",
            },
            name: {
                type: "string",
                description: "影院名称",
            },
            address: {
                type: "string",
                description: "影院地址",
            },
            phone: {
                type: "number",
                description: "联系电话",
            },
            price: {
                type: "number",
                description: "票价",
            },
            distance: {
                type: "string",
                description: "距离",
            },
            status: {
                type: "string",
                description: "影院是否开启",
            },
        }
    },
    selectInfo: {
        properties: {
            messageFormat: {
                type: "string",
                description: "",
            },
            stringValue:{
                type: "string",
                description: "",
            },
            kind:{
                type: "string",
                description: "",
            },
            value:{
                type: "string",
                description: "",
            },
            path: {
                type: "string",
                description: "",
            },
            reason:{
                type: "string",
                description: "",
            },
            valueType:{
                type: "string",
                description: "",
            },


        }
    },
    deleteCinemas:{
        properties:{
            status:{
                type: "boolean",
                description: "返回值状态",
            }
        }
    }
}
const paths = {
    // 获取影院接口
    "/cinemas": {
        get: {
            // 路径挂载
            tags: ["cinemas"],
            summary: "获取影院信息",
            description: "这里可以获取到影院信息",
            // 请求数据类型 json
            consumes: ["application/json"],
            // 需要传入的参数
            parameters: [
                {
                    name: "curPage",
                    // 参数从哪获取
                    in: "query",
                    schema: {
                        type: "integer",
                        default: 1,
                    },
                    required: true,
                    description: "当前⻚码",
                },
                {
                    name: "eachPage",
                    in: "query",
                    schema: {
                        type: "integer",
                        default: 1,
                    },
                    required: true,
                    description: "每⻚条数",
                },
            ],
            responses: {
                200: {
                    description: "成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/ArrayOfCinemasReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },

        //新增影院接口
        post: {
            tags: ["cinemas"],
            summary: "新增影院信息",
            description: "这里可以做新增影院操作",

            requestBody: {
                required: true,
                content: {
                    "application/json": {
                        schema: {
                            $ref: "#/components/schemas/ArrayOfCinemasReturn",
                        },
                        example: {
                            name: '北岸影院',
                            address: '成华区成华大道',
                            phone: 12685974635,
                            price: 20,
                            distance: '2km',
                            status: 'true',
                        },
                    },
                },
            },
            responses: {
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/ArrayOfCinemasReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        }
    },
    "/cinemas/:_id": {
        // 通过影院id查找影院信息
        get: {
            // 路径挂载
            tags: ["cinemas"],
            summary: "查找影院信息",
            description: "这里可以查找到影院信息",
            // 请求数据类型 json
            consumes: ["application/json"],
            parameters: [
                {
                    name: "_id",
                    // 参数从哪获取
                    in: "params",
                    required: true,
                    description: "影院id值",
                },

            ],
            responses: {
                200: {
                    description: "成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/ArrayOfCinemasReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
        // 删除影院数据
        delete: {
            // 路径挂载
            tags: ["cinemas"],
            summary: "删除影院信息",
            description: "这里可以删除影院信息",
            // 请求数据类型 json
            consumes: ["application/json"],
            parameters: [
                {
                    name: "_id",
                    // 参数从哪获取
                    in: "body",
                    required: true,
                    description: "影院id值",
                },

            ],
            responses: {
                200: {
                    description: "成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/deleteCinemas",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
        // 修改影院数据
        put: {
            // 路径挂载
            tags: ["cinemas"],
            summary: "修改影院信息",
            description: "这里可以修改影院信息",
            // 请求数据类型 json
            consumes: ["application/json"],
            parameters: [
                {
                    name: "_id",
                    // 参数从哪获取
                    in: "body",
                    required: true,
                    description: "影院id值",
                },
                {
                    name: "name",
                    // 参数从哪获取
                    in: "body",
                    required: true,
                    description: "影院名称",
                },
                {
                    name: "address",
                    // 参数从哪获取
                    in: "body",
                    required: true,
                    description: "影院地址",
                },
                {
                    name: "phone",
                    // 参数从哪获取
                    in: "body",
                    required: true,
                    description: "联系电话",
                },
                {
                    name: "price",
                    // 参数从哪获取
                    in: "body",
                    required: true,
                    description: "价格",
                },
                {
                    name: "distance",
                    // 参数从哪获取
                    in: "body",
                    required: true,
                    description: "距离",
                },
                {
                    name: "status",
                    // 参数从哪获取
                    in: "body",
                    required: true,
                    description: "影院是否开门",
                },


            ],
            responses: {
                200: {
                    description: "成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/deleteCinemas",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
        // 上传图片
        patch: {
            // 路径挂载
            tags: ["cinemas"],
            summary: "上传影院图片信息",
            description: "这里可以上传影院图片信息",
            // 请求数据类型 json
            consumes: ["application/json"],
            parameters: [
                {
                    name: "_id",
                    // 参数从哪获取
                    in: "body",
                    required: true,
                    description: "影院id值",
                },

            ],
            responses: {
                200: {
                    description: "成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/deleteImg",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    },
    // 删除图片
    "/cinemas/:_id/imgs/:url": {
        delete: {
            // 路径挂载
            tags: ["cinemas"],
            summary: "删除影院图片信息",
            description: "这里可以删除影院图片信息",
            // 请求数据类型 json
            consumes: ["application/json"],
            parameters: [
                {
                    name: "_id",
                    // 参数从哪获取
                    in: "params",
                    required: true,
                    description: "影院id值",
                },
                {
                    name: "url",
                    // 参数从哪获取
                    in: "params",
                    required: true,
                    description: "影院id值",
                },

            ],
            responses: {
                200: {
                    description: "成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/deleteImg",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        }
    },
    // 筛选信息
    "/cinemas/select": {
        get: {
            // 路径挂载
            tags: ["cinemas"],
            summary: "获取所有影院信息",
            description: "这里可以获取所有影院信息",
            // 请求数据类型 json
            consumes: ["application/json"],
            parameters: [
                {
                    name: "slectInfo",
                    // 参数从哪获取
                    in: "query",

                    required: true,
                    description: "这是一个搜索条件",
                },

            ],
            responses: {
                200: {
                    description: "成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/selectInfo",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        }
    }
}

module.exports = { tag, paths, schemas }